<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /*
        属性独立，方法共享（原型）
      */
      let hamster = {
        stomach: [],
        eat(food) {
          this.stomach.push(food);
        },
      };
      // [apple]
      let speedy = { stomach: [], __proto__: hamster };
      let lazy = { stomach: [], __proto__: hamster };

      speedy.eat("apple");
      console.log(speedy.stomach); // ["apple"]
      console.log(lazy.stomach); // ["apple"]

      console.log(hamster);
    </script>
  </body>
</html>
